package com.eqdd.yiqidian.rongyun.plugin;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;

import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.base.AppConstent;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.bean.SelectBean;
import com.eqdd.yiqidian.bean.rebuild.ShareConf;
import com.eqdd.yiqidian.bean.rebuild.ShareEnterConf;
import com.eqdd.yiqidian.bean.rebuild.UserCardInfoResultBean;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.http.HttpResult;
import com.eqdd.yiqidian.http.JsonCallBack;
import com.eqdd.yiqidian.ui.mine.renwu.CreateRenwuActivity;
import com.eqdd.yiqidian.ui.share.ShareEnterActivity;
import com.eqdd.yiqidian.utils.ToastUtil;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

import java.util.ArrayList;

import io.rong.imkit.RongExtension;
import io.rong.imkit.RongIM;
import io.rong.imkit.plugin.IPluginModule;
import io.rong.imkit.userInfoCache.RongUserInfoManager;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.imlib.model.UserInfo;

/**
 * Created by lvzhihao on 17-4-30.
 */

public class RenwuPluginModel implements IPluginModule {
    Conversation.ConversationType conversationType;
    String targetId;

    @Override
    public Drawable obtainDrawable(Context context) {
        //设置插件 Plugin 图标
        return ContextCompat.getDrawable(context, R.drawable.renwu_selector);
    }

    @Override
    public String obtainTitle(Context context) {
        //设置插件 Plugin 展示文字
        return "任务";
    }

    @Override
    public void onClick(final Fragment currentFragment, RongExtension extension) {
        //示例获取 会话类型、targetId、Context,此处可根据产品需求自定义逻辑，如:开启新的 Activity 等。
        conversationType = extension.getConversationType();
        targetId = extension.getTargetId();
        if (AppConstent.user.getCompanyId() == 0) {
            ToastUtil.showShort("请先加入公司再发任务");
        } else {
            UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId);
            if (userInfo == null) {
                ToastUtil.showShort("你无法给该用户发任务");
            } else {
                Intent intent = new Intent(currentFragment.getActivity(), CreateRenwuActivity.class);
                intent.putExtra(Config.GUID, targetId);
                intent.putExtra(Config.NAME, userInfo.getName());
                extension.startActivityForPluginResult(intent, Config.CREATE_RENWU, this);
            }
        }

    }

    @Override
    public void onActivityResult(int i, int i1, Intent intent) {

    }

}
